package co.baiku.boot.common.type;

import java.util.HashMap;
import java.util.Map;

public enum BrowserType implements IEnum<BrowserType, Integer> {
    Chrome(1, "谷歌浏览器"), IE(2, "IE浏览器"),
    Firefox(3, "火狐浏览器"), Android(4, "安卓浏览器"),
    Safari(5, "Safari浏览器"), Wechat(6, "微信浏览器"),
    Alipay(7, "支付宝浏览器"), Unkown(99, "其他浏览器");

    Integer value;
    String description;

    private final static Map<Integer, BrowserType> CACHE = new HashMap<>();

    BrowserType(Integer value, String description) {
        this.description = description;
        this.value = value;
    }

    @Override
    public Integer getValue() {
        return null;
    }

    @Override
    public String getDescription() {
        return null;
    }

    @Override
    public BrowserType parseValue(Integer value) {
        if (CACHE.isEmpty()) {
            for (BrowserType browserType : values()) {
                CACHE.put(browserType.getValue(), browserType);
            }
        }
        return CACHE.get(value);
    }
}
